//
//  BGMessageBasicCell.m
//  bigMall
//
//  Created by LTOVE on 16/7/21.
//  Copyright © 2016年 thinklev. All rights reserved.
//

#import "BGMessageBasicCell.h"
#import "BGMessageNameAndValueModel.h"
#import "BGMessageDataModel.h"
#import "MJExtension.h"
#import "BGMessageViewHeader.h"

#import "BGMessageContentFrameModel.h"

#import "BGMessageListCellView.h"
#import "BGProductParamModel.h"
static NSString *const reuserIdentify = @"cell";
@interface BGMessageBasicCell (){
    
    UIView *_ContentView;
    NSString *_unit;
    BOOL _isDealloc;
    BGMessageCountDown *_timeView;
}

@end

@implementation BGMessageBasicCell


- (void)setFmodel:(BGMessageContentFrameModel *)Fmodel
{
    _Fmodel = Fmodel;
    _unit = Fmodel.unit;
    GWLog(@"%@",[Fmodel.dataModel class]);
    //创建内容视图
    [self setUpContentViewWithCellHeigh:Fmodel.cellHeigh];
    //创建对应视图 设置对应数据
    [self setUpAllSubviewsWithClass:Fmodel.dataModel];
}

+ (UITableViewCell *)cellWithTableView:(UITableView *)tableView IndexPath:(NSIndexPath *)indexPath
{
    BGMessageBasicCell *cell = [tableView dequeueReusableCellWithIdentifier:reuserIdentify];
    if (!cell) {
        cell = [[self alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:reuserIdentify];
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

- (void)setUpContentViewWithCellHeigh:(CGFloat)cellHeigh
{
    for (UIView *view in self.contentView.subviews) {
        [view removeFromSuperview];
    }
    UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 0, screenW, cellHeigh)];
    view.backgroundColor = dockwhite_;
    _ContentView = view;
    [self.contentView addSubview:_ContentView];
}
/**
 *  根据对应得模型加载对应的视图
 */
- (void)setUpAllSubviewsWithClass:(BGMessageContentModel * )model
{
    
    GWLog(@"%@",[model class]);
    if ([model isKindOfClass:[BGViewladderpriceDataModel class]]){
        NSLog(@"ds");
    }
#warning 待完成
    if ([model isKindOfClass:[BGAuctionTopViewDataModel class]]) {
        //拍卖详情页面顶部视图
        BGAuctionTopViewDataModel *iteModel = (BGAuctionTopViewDataModel *)model;
        UIView *TitleView = [BGMessageTitleView initWidthFrame:CGRectMake(0, 0, screenW, BGTitleHeigh) andTitle:iteModel.title andSecTitle:iteModel.secTitle andIsTop:YES];
        [_ContentView addSubview:TitleView];
        //中间视图
        UIView *midView = [BGMessageTopMidView initWithFrame:CGRectMake(BGMaginLeft, CGRectGetMaxY(TitleView.frame), screenW - BGMaginLeft - BGMaginRight, BGTopMidViewHeigh) andDataArray:iteModel.middleViewDataArray andUnit:_unit];
        [_ContentView addSubview:midView];
        //倒计时
//        UIView *countDownView = [BGMessageCountDown initWithFram:CGRectMake(0, CGRectGetMaxY(midView.frame) + BGMaginTop, screenW, BGTitleHeigh) andTimesString:iteModel.endTime];
//        [_ContentView addSubview:countDownView];
    }else if ([model isKindOfClass:[BGAuctionDetailsDataModel class]]){
#pragma mark -12-9 报价
        //拍卖详情页面 拍卖详情模块数据模型
        BGAuctionDetailsDataModel *itemModel = (BGAuctionDetailsDataModel *)model;
        if ([itemModel.title isEqualToString:@"投标记录"]) {
            [self SetUpContentListViewWith:itemModel.dataArray andTitle:itemModel.title andIdDouble:YES];
        }else{
            [self addProductParamWithTitle:itemModel.title andDataArray:itemModel.dataArray];
        }
//
        
        
        
        
//        UIView *auctionDetailView = [BGMessageTitleView initWidthFrame:CGRectMake(0, 0, screenW, BGTitleHeigh) andTitle:itemModel.title andSecTitle:nil andIsTop:NO];
//        [_ContentView addSubview:auctionDetailView];
//        //内容列表视图
//        UIView *ContentListView = [BGMessageListLayout initWithFrame:CGRectMake(0, CGRectGetMaxY(auctionDetailView.frame), screenW, _ContentView.height - BGMaginButtom - auctionDetailView.height) andDataArray:itemModel.dataArray andIsDouble:YES];
//        [_ContentView addSubview:ContentListView];
    }else if ([model isKindOfClass:[BGProductParamDataModel class]]){
        //拍卖详情页面  产品参数模块
        BGProductParamDataModel *itemModel = (BGProductParamDataModel *)model;
        [self SetUpContentListViewWith:itemModel.dataArray andTitle:itemModel.title andIdDouble:YES];
    }else if ([model isKindOfClass:[BGBidRecordDataModel class]]){
        //产品详情页面  出价记录模块
        NSLog(@"%@",[model class]);
        NSLog(@"%@",[BGBidRecordDataModel class]);
        BGBidRecordDataModel *itemModel = (BGBidRecodeDataModel *)model;
        UIView *View = [BGMessageTitleView initWidthFrame:CGRectMake(0, 0, screenW, BGTitleHeigh) andTitle:itemModel.title andSecTitle:nil andIsTop:NO];
        [_ContentView addSubview:View];
    }else if ([model isKindOfClass:[BGProductDetialDataModel class]]){
        //商品详情页面的 顶部视图数据模型
        BGProductDetialDataModel *itemModel = (BGProductDetialDataModel *)model;
        UIView *titleView = [BGMessageTitleView initWidthFrame:CGRectMake(0, 0, screenW, BGTitleHeigh) andTitle:itemModel.title andSecTitle:itemModel.secStr andIsTop:YES];
        titleView.backgroundColor = [UIColor whiteColor];
        [_ContentView addSubview:titleView];
        UIView *midView = [BGMessageTopMidView initWithFrame:CGRectMake(0, CGRectGetMaxY(titleView.frame), screenW, BGTopMidViewHeigh) andDataArray:itemModel.middleViewDataArray andUnit:_unit];
//        midView.backgroundColor = GWColor(242, 243, 244, 1);
        [_ContentView addSubview:midView];
        
//        UIView *oneLineView = [BGMessageListLayout initWithFrame:CGRectMake(0, CGRectGetMaxY(midView.frame), screenW, itemModel.oneLineContentListArray.count * BGTitleHeigh) andDataArray:itemModel.oneLineContentListArray andIsDouble:NO];
//        [_ContentView addSubview:oneLineView];
        NSInteger temp = itemModel.isDouble ? itemModel.doubleLineContentListArray.count : (itemModel.doubleLineContentListArray.count + 1) / 2;;
        
        UIView *doubleLineView = [BGMessageListLayout initWithFrame:CGRectMake(0, CGRectGetMaxY(midView.frame), screenW, temp * BGMagListMaginY + temp * BGLabelHeigh) andDataArray:itemModel.doubleLineContentListArray andIsDouble:!itemModel.isDouble];
        [_ContentView addSubview:doubleLineView];
        UIColor *color = [UIColor grayColor];
        BGMessageCountDown *cutDownView = [BGMessageCountDown initWithFram:CGRectMake(0, CGRectGetMaxY(doubleLineView.frame), screenW, 5 + 2 * BGMaginTop + 2 * BGLabelHeigh) andTimesString:itemModel.endTime andTitle:@"距离商品下架还剩" andColor:color];
//        cutDownView.isDelloc = _isDealloc;
        _timeView = cutDownView;
//        [BGMessageCountDown initWithFram:<#(CGRect)#> andTimesString:<#(NSString *)#> andTitle:<#(NSString *)#> andColor:color]
        [_ContentView addSubview:cutDownView];
        
        
    }else if ([model isKindOfClass:[BGViewladderpriceDataModel class]]){
       // 查看阶梯价格
        
        UIView *visitView = [BGVisitDeTailPriceView initVisitViewWithCellHeigh:45];
        self.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
        [_ContentView addSubview:visitView];
#warning 视图没有创建呢还
        
    }else if([model isKindOfClass:[BGProductParamModel class]]){
    BGProductParamModel *itemModel = (BGProductParamModel *)model;
#pragma mark - 产品指标
        [self addProductParamWithTitle:itemModel.title andDataArray:itemModel.dataArray];
    }else if ([model isKindOfClass:[BGProductIndexDataModel class]]){
        //商品详情  产品指标
        BGProductIndexDataModel *itemModel = (BGProductIndexDataModel *)model;
        [self SetUpContentListViewWith:itemModel.dataArray andTitle:itemModel.title andIdDouble:YES];
        
        [self addProductParamWithTitle:itemModel.title andDataArray:itemModel.dataArray];
        
    }else if ([model isKindOfClass:[BGQCreportDataModel class]]){
        //商品详情 质检报告
        BGQCreportDataModel *itemModel = (BGQCreportDataModel *)model;
        UIView *titleView = [BGMessageTitleView initWidthFrame:CGRectMake(0, 0, screenW, BGTitleHeigh) andTitle:itemModel.title andSecTitle:nil andIsTop:NO];
        [_ContentView addSubview:titleView];
        UIView *contentView = [BGMessageImageView initWithFrame:CGRectMake(0, CGRectGetMaxY(titleView.frame), screenW, ((itemModel.imageDataArray.count + 1) /2 ) * BGImgListHeigh + ((itemModel.imageDataArray.count + 1) /2 +1) * BGMagListMaginY) andDataArray:itemModel.imageDataArray];
        [_ContentView addSubview:contentView];
    }else if ([model isKindOfClass:[BGGivePriceTopViewDataModel class]]){
        //报价顶部视图
        BGGivePriceTopViewDataModel *itemModel = (BGGivePriceTopViewDataModel *)model;
        UIView *titleView = [BGMessageTitleView initWidthFrame:CGRectMake(0, 0, screenW, BGTitleHeigh) andTitle:itemModel.title andSecTitle:itemModel.secTitle andIsTop:YES];
        [_ContentView addSubview:titleView];
        UIView *midView = [BGMessageTopMidView initWithFrame:CGRectMake(0, CGRectGetMaxY(titleView.frame), screenW, BGTopMidViewHeigh) andDataArray:itemModel.middleViewDataArray andUnit:_unit];
        [_ContentView addSubview:midView];
        UIView *oneLineView = [BGMessageListLayout initWithFrame:CGRectMake(0, CGRectGetMaxY(midView.frame), screenW, BGMaginTop + BGMaginButtom + itemModel.oneContentArray.count * BGTitleHeigh) andDataArray:itemModel.oneContentArray andIsDouble:NO];
        [_ContentView addSubview:oneLineView];
        UIView *beginTimeView = [BGMessageBeginTimeView initWithFrame:CGRectMake(0, CGRectGetMaxY(oneLineView.frame), screenW,BGMaginTop + BGMaginButtom + 2 * BGTitleHeigh) andBeginTime:itemModel.beginTime andEndTime:itemModel.endTime];
        [_ContentView addSubview:beginTimeView];
    }else if ([model isKindOfClass:[BGinfoMessageDataModel class]]){
        //报价页面  基本信息
        BGinfoMessageDataModel *itemModel = (BGinfoMessageDataModel *)model;
        [self SetUpContentListViewWith:itemModel.dataArray andTitle:itemModel.title andIdDouble:YES];
    }else if ([model isKindOfClass:[BGGoodInfoDataModel class]]){
        //报价页面  产品信息模块
        BGGoodInfoDataModel *itemModel = (BGGoodInfoDataModel *)model;
        [self SetUpContentListViewWith:itemModel.dataArray andTitle:itemModel.title andIdDouble:YES];
    }else if ([model isKindOfClass:[BGBidRecodeDataModel class]]){
        //报价页面  投标记录标题
        BGBidRecodeDataModel *itemModel = (BGBidRecodeDataModel *)model;
        UIView *titleView = [BGMessageTitleView initWidthFrame:CGRectMake(0, 0, screenW, _ContentView.height) andTitle:itemModel.title andSecTitle:nil andIsTop:NO];
        [_ContentView addSubview:titleView];
    }else if ([model isKindOfClass:[BGBidRecodeListDataModelAuCtion class]]){
        //报价页面  投标记录列表模块
        BGBidRecodeListDataModel *itemModel = (BGBidRecodeListDataModel *)model;
        
        UIView *view = [BGMessageListCellView initWithFrame:CGRectMake(0, 0, screenW, _ContentView.height) andIsColor:YES andIsBid:NO andUserName:itemModel.title andDateText:itemModel.datetext andContentText:itemModel.contentText];
        
//             view
        
        [_ContentView addSubview:view];
    }else if ([model isKindOfClass:[BGBidRecodeListDataModel class]]){
        //拍卖详情 出价记录列表数据模型
//        BGbidRecordListDataModel *itemModel = (BGbidRecordListDataModel *)model;
        BGBidRecodeListDataModel *itemModel = (BGBidRecodeListDataModel *)model;
        UIView *listCellView = [BGMessageListCellView initWithFrame:CGRectMake(0, 0, screenW, _ContentView.height) andIsColor:itemModel.isColor andIsBid:itemModel.isBid andUserName:itemModel.title andDateText:itemModel.datetext andContentText:itemModel.contentText];
        [_ContentView addSubview:listCellView];
    }
}
#pragma mark - 增加产品指标
/***
    增加产品指标
 */
- (void)addProductParamWithTitle:(NSString *)title andDataArray:(NSArray *)array
{
//    NSLog(@"%@",array);
//    [array writeToFile:@"/Users/LTOVE/Desktop/array.plist" atomically:YES];
    NSMutableArray *MutableArray = [NSMutableArray array];
    for (int i = 0 ; i < array.count; i ++) {
        BGMessageNameAndValueModel *model = [BGMessageNameAndValueModel objectWithKeyValues:array[i]] ;
        //        GWLog(@"%@",model.value);
        NSString *str =  [NSString stringWithFormat:@"%@: %@",model.title,model.value];
        NSDictionary *attDic = @{
                                 NSFontAttributeName:[UIFont systemFontOfSize:12],
                                 NSForegroundColorAttributeName:BGtextGraykColor,
                                 };
        NSMutableAttributedString *attr = [[NSMutableAttributedString alloc]initWithString:str attributes:attDic];
        NSRange rang = [str rangeOfString:@":"];
        NSUInteger location =  0;
        [attr addAttribute:NSForegroundColorAttributeName value:[UIColor blackColor] range:NSMakeRange(location, rang.location + 1)];
        [MutableArray addObject:attr];
    }
    
    for (UIView *view in self.contentView.subviews) {
        if ([view isKindOfClass:[UIView class]]) {
            [view removeFromSuperview];
        }
    }
//    标题
    UIView *titleView = [UIView new];
    [self.contentView addSubview:titleView];
    titleView.translatesAutoresizingMaskIntoConstraints = NO;
    //titleView高约束
    [titleView addConstraint:[NSLayoutConstraint constraintWithItem:titleView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant:45]];
    //顶部约束
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:titleView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]];
    //左边约束
    [self.contentView  addConstraint:[NSLayoutConstraint constraintWithItem:titleView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]];
    //右边约束
    [self.contentView  addConstraint:[NSLayoutConstraint constraintWithItem:titleView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0]];
    if (array.count == 0) {
        //下部约束
        [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:titleView attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]];
    }
    //titleLabel
    UILabel *label = [UILabel new];
    label.translatesAutoresizingMaskIntoConstraints = NO;
    label.text = title;
    label.font = Font34;
    label.textColor = BGtextBlackColor;
    [label sizeToFit];
    [titleView addSubview:label];
    //centerY约束
    [titleView addConstraint:[NSLayoutConstraint constraintWithItem:label attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:titleView attribute:NSLayoutAttributeCenterY multiplier:1.0 constant:0]];
//    left约束
    [titleView addConstraint:[NSLayoutConstraint constraintWithItem:label attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:titleView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:BGMaginLeft]];
//    分割线
    UIView *lineView = [UIView new];
    lineView.backgroundColor = dockwhite_;
    lineView.translatesAutoresizingMaskIntoConstraints = NO;
    [self.contentView addSubview:lineView];
    //高约束
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:lineView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant:1]];
    //顶部约束
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:lineView attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:titleView attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]];
    //左边约束
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:lineView attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeLeft multiplier:1.0 constant:0]];
    //右边约束
    [self.contentView addConstraint:[NSLayoutConstraint constraintWithItem:lineView attribute:NSLayoutAttributeRight relatedBy:NSLayoutRelationEqual toItem:self.contentView attribute:NSLayoutAttributeRight multiplier:1.0 constant:0]];
//    列表
    NSMutableAttributedString *firstTitle = [[NSMutableAttributedString alloc]init];
    NSMutableAttributedString *twoTitle = [NSMutableAttributedString new];
    NSDictionary *viewDic = NSDictionaryOfVariableBindings(lineView);
    NSMutableDictionary *dic = [[NSMutableDictionary alloc]initWithDictionary:viewDic];
    int j = 0;
    for (int i = 0; i < MutableArray.count; i++) {
        if (i % 2 == 0 ) {
            firstTitle = MutableArray[i];
        }else{
            twoTitle = MutableArray[i];
        }
        if (i % 2 != 0 && i <= MutableArray.count -1) {
            
            UIView *view =  [self viewWithTitle:firstTitle secTitle:twoTitle];
            view.translatesAutoresizingMaskIntoConstraints = NO;
            [self.contentView addSubview:view];
            [dic setObject:view forKey:[NSString stringWithFormat:@"view%d",j]];
            j++;
        }else if (i % 2 == 0 && i == MutableArray.count - 1){
            twoTitle = [[NSMutableAttributedString alloc]initWithString:@""];
            UIView *view =  [self viewWithTitle:firstTitle secTitle:twoTitle];
            view.translatesAutoresizingMaskIntoConstraints = NO;
            [self.contentView addSubview:view];
            [dic setObject:view forKey:[NSString stringWithFormat:@"view%d",j]];
            j++;
        }
    }
    NSLog(@"%@",dic);
    for (int i = 0; i < j; i++) {
        if (j == 1) {
//            [self addConstranitWithTopView:[NSString stringWithFormat:@"view%d",i - 1] BouutomView:[NS String stringWithFormat:@"view%d",i + 1] view:[NSString stringWithFormat:@"view%d",i] dic:dic isTop:YES];
            
            [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"|[view0]|" options:0 metrics:nil views:dic]];
            [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:@"V:[lineView]-5-[view0]-5-|" options:0 metrics:nil views:dic]];
        }else if (i == 0) {
            [self addConstranitWithTopView:@"lineView" BouutomView:[NSString stringWithFormat:@"view%d",i + 1] view:[NSString stringWithFormat:@"view%d",i] dic:dic isTop:YES];
        }else if (i == j -1){
            [self addConstranitWithTopView:[NSString stringWithFormat:@"view%d",i - 1] BouutomView:nil view:[NSString stringWithFormat:@"view%d",i] dic:dic isTop:NO];
        }else{
            [self addConstranitWithTopView:[NSString stringWithFormat:@"view%d",i - 1] BouutomView:[NSString stringWithFormat:@"view%d",i + 1] view:[NSString stringWithFormat:@"view%d",i] dic:dic isTop:YES];
        }
        
    }
}

- (void)addConstranitWithTopView:(NSString *)top BouutomView:(NSString *)bom view:(NSString *)view dic:(NSMutableDictionary *)dic isTop:(BOOL )isTop
{
    NSString *Hstr = [NSString stringWithFormat:@"|[%@]|",view];
    NSString *Vstr = isTop? [NSString stringWithFormat:@"V:[%@]-5-[%@]",top,view] : [NSString stringWithFormat:@"V:[%@]-5-|",view];
    [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:Hstr options:0 metrics:nil views:dic]];
    [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:Vstr options:0 metrics:nil views:dic]];
    if (!isTop) {
        [self.contentView addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:[NSString stringWithFormat:@"V:[%@]-5-[%@]",top,view] options:0 metrics:nil views:dic]];
    }
}

/***
    每一行的列表
 */
- (UIView *)viewWithTitle:(NSMutableAttributedString *)title secTitle:(NSMutableAttributedString *)secTitle
{
    UIView *view = [UIView new];
    view.translatesAutoresizingMaskIntoConstraints = NO;
    [view addConstraint:[NSLayoutConstraint constraintWithItem:view attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:0.0 constant:screenW]];
    //第一个label
    UILabel *labelOne = [UILabel new];
    labelOne.translatesAutoresizingMaskIntoConstraints = NO;
    labelOne.attributedText = title;
    labelOne.numberOfLines = 0;
//    labelOne.adjustsFontSizeToFitWidth = YES;
    [labelOne sizeToFit];
    [view addSubview:labelOne];
    //第二个label
    UILabel *twoLabel = [UILabel new];
    twoLabel.translatesAutoresizingMaskIntoConstraints = NO;
    twoLabel.numberOfLines = 0;
    twoLabel.attributedText = secTitle;
    [twoLabel sizeToFit];
    [view addSubview:twoLabel];
    //顶部约束
    [view addConstraint:[NSLayoutConstraint constraintWithItem:labelOne attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]];
    [view addConstraint:[NSLayoutConstraint constraintWithItem:twoLabel attribute:NSLayoutAttributeTop relatedBy:NSLayoutRelationEqual toItem:view attribute:NSLayoutAttributeTop multiplier:1.0 constant:0]];
    //左边约束
    [view addConstraint:[NSLayoutConstraint constraintWithItem:labelOne attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:view attribute:NSLayoutAttributeLeft multiplier:1.0 constant:BGMaginLeft]];
    //右边约束
    [view addConstraint:[NSLayoutConstraint constraintWithItem:twoLabel attribute:NSLayoutAttributeLeft relatedBy:NSLayoutRelationEqual toItem:labelOne attribute:NSLayoutAttributeRight multiplier:1.0 constant:0]];
    //宽度约束
    [view addConstraint:[NSLayoutConstraint constraintWithItem:labelOne attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:nil attribute:NSLayoutAttributeNotAnAttribute multiplier:1.0 constant:(screenW - 2 * BGMaginLeft) / 2.0]];
    [view addConstraint:[NSLayoutConstraint constraintWithItem:twoLabel attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:labelOne attribute:NSLayoutAttributeWidth multiplier:1.0 constant:0]];
    //底部约束
    if (title.length > secTitle.length) {
        [view addConstraint:[NSLayoutConstraint constraintWithItem:labelOne attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]];
    }else{
        [view addConstraint:[NSLayoutConstraint constraintWithItem:twoLabel attribute:NSLayoutAttributeBottom relatedBy:NSLayoutRelationEqual toItem:view attribute:NSLayoutAttributeBottom multiplier:1.0 constant:0]];
    }
    return view;
}
/**
 *  增加内容视图
 *
 *  @param dataArray dataArray description
 *  @param title     title description
 *  @param isDouble  isDouble description
 */
- (void)SetUpContentListViewWith:(NSArray * )dataArray andTitle:(NSString *)title andIdDouble:(BOOL)isDouble
{
    UIView *auctionDetailView = [BGMessageTitleView initWidthFrame:CGRectMake(0, 0, screenW, BGTitleHeigh) andTitle:title andSecTitle:nil andIsTop:NO];
//    auctionDetailView.backgroundColor = [UIColor whiteColor];
    [_ContentView addSubview:auctionDetailView];
    //内容列表视图
    UIView *ContentListView = [BGMessageListLayout initWithFrame:CGRectMake(0, CGRectGetMaxY(auctionDetailView.frame), screenW, BGLabelHeigh *(dataArray.count + 1) / 2 + (((dataArray.count + 1) / 2) + 1) * BGMagListMaginY  ) andDataArray:dataArray andIsDouble:isDouble];
//    GWLog(@"%lu",(dataArray.count + 1) / 2 + (((dataArray.count + 1) / 2) + 1) * BGMagListMaginY);
    [_ContentView addSubview:ContentListView];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];
    
    // Configure the view for the selected state
}

- (void)dealloc
{
    NSLog(@"cell 消失");
//    _isDealloc = YES;
    _timeView.isDelloc = YES;
    
}

@end
